<template>
  <div :class="className" :style="{height:height,width:width}" />
</template>

<script>
import * as echarts from 'echarts'
require('echarts/theme/macarons')
import resize from '@/views/bioAuthData/mixins/resize'
export default {
  name: 'PieChartSoftBio',
  mixins: [resize],
  props: {
    className: {
      type: String,
      default: 'chart2'
    },
    width: {
      type: String,
      default: '500px'
    },
    height: {
      type: String,
      default: '300px'
    }
  },
  data() {
    return {
      chart: null
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.initChart()
    })
  },
  beforeDestroy() {
    if (!this.chart) {
      return
    }
    this.chart.dispose()
    this.chart = null
  },
  methods: {
    initChart() {
      this.chart = echarts.init(this.$el, 'macarons')
      this.chart.setOption({
        title: {
          show: true,
          text: '软生物特征占比',
          textStyle: {
            fontSize: 20,
            fontWeight: 'normal',
            color: ['#fff']
          },
          top: 320
        },
        tooltip: {
          trigger: 'item',
          backgroundColor: 'rgba(255,255,255,0.8)', // 设置背景图片 rgba格式
          color: 'black',
          borderWidth: '1', // 边框宽度设置1
          borderColor: 'gray', // 设置边框颜色
          textStyle: {
            color: 'black' // 设置文字颜色
          },
          formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: {
          left: 'center',
          bottom: '10',
          data: ['认证成功(指纹)', '认证成功(人脸)', '认证成功(其他)', '认证失败']
        },
        series: [
          {
            name: '认证结果',
            type: 'pie',
            data: [
              { value: 1409044221, name: '认证成功(指纹)' },
              { value: 1409044221, name: '认证成功(人脸)' },
              { value: 313120900, name: '认证成功(其他)' },
              { value: 3131209, name: '认证失败' }
              // { value: 0, name: '认证失败(人脸)' },
              // { value: 38, name: '认证失败(其他)' }
            ],
            animationEasing: 'cubicInOut',
            animationDuration: 2000
          }
        ]
      })
    }
  }
}
</script>

<style scoped>

</style>
